home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS6.ZIP / DOSCOLOR < prev    next >
Text File  |  1987-02-04  |  5KB  |  137 lines

  1.                           Color Me DOS
  2.          (PC Magazine Vol 6 No 3 Feb 10, 1987 PC Tutor)
  3.  
  4.      The most hassle-free method of getting some color on the DOS
  5. command level is by using ANSI.SYS and the PROMPT command.  The prompt
  6. is the thing that normally looks like:
  7.  
  8. C>
  9.  
  10. and the PROMPT command lets you change it.
  11.      ANSI.SYS is a device driver that comes with DOS.  You can instruct
  12. DOS to load ANSI.SYS by adding the following line in your CONFIG.SYS
  13. file:
  14.  
  15. DEVICE=ANSI.SYS
  16.  
  17. If you don't have a CONFIG.SYS file, you can create one with EDLIN.
  18. If you keep ANSI.SYS in a subdirectory (called DOS, for instance), the
  19. line would read:
  20.  
  21. DEVICE=\DOS\ANSI.SYS
  22.  
  23. The next time you reboot, ANSI.SYS will be loaded.  Now with ANSI.SYS
  24. loaded, enter:
  25.  
  26. PROMPT $e[35;44;1m$p$g$e[33;44;1m
  27.  
  28. This gibberish creates a magenta prompt and yellow text on a blue
  29. background.  You can color the whole background blue by executing a
  30. CLS command.  If you're fond of that color combination, you can put
  31. this line in your AUTOEXEC.BAT file in your root directory.
  32.      The ANSI.SYS device driver allows applications programs to control
  33. the video display using control sequences standardized by the American
  34. National Standards Institute (ANSI).  PC applications programs that
  35. actually use ANSI control sequences, however, are very rare.  Most
  36. applications programs control the display in other ways.
  37.      The ANSI.SYS control sequences are not documented in the DOS
  38. manuals for Versions 2.1 or later.  They can be found in the DOS
  39. Technical Reference manual, however.  The remainder of the DOS
  40. Technical Reference is essential for assembly language programmers,
  41. useful for other programmers, and a waste for people who don't need
  42. (or want) to know about the internals of DOS.
  43.      All the ANSI control sequences begin with an escape character
  44. (hexadecimal 1Bh) and a left bracket.  The $e used in the PROMPT
  45. command is the code that PROMPT uses for an escape character.  The
  46. control sequences to control color end with the letter m.  Between the
  47. left bracket and the m is a series of numbers separated by semicolons.
  48. These numbers specify the color.  They are:
  49.  
  50. Color    Foreground    Background
  51. -----    ----------    ----------
  52. Black       30            40
  53. Red       31            41
  54. Green       32            42
  55. Brown       33            43
  56. Blue       34            44
  57. Magenta       35            45
  58. Cyan       36            46
  59. White       37            47
  60.  
  61.      A number 1 following a background and foreground number turns on
  62. high intensity for the foreground.  This is generally necessary for
  63. text on a colored background.  A high-intensity brown is yellow.
  64.      The $p$g in the PROMPT command is the non-ANSI part of the prompt.
  65. As you can note from the documentation of PROMPT in the DOS manual,
  66. this is a good prompt for a hard disk user, since it shows you both
  67. the current drive and directory.
  68.      Another popular method for coloring the display uses BASIC.  You
  69. can create a small BASIC program (called, for instance, COLOR.BAS) that
  70. looks like:
  71.  
  72. 10 COLOR 14,1
  73. 20 CLS
  74. 30 SYSTEM
  75.  
  76. Then, when you execute:
  77.  
  78. BASICA COLOR
  79.  
  80. you'll be back on the DOS command level with yellow text on a blue
  81. background.  (The color codes used in BASIC are documented in the BASIC
  82. manual under the COLOR statement.  Naturally, they are entirely
  83. different from the ANSI.SYS color codes.)  You could put the line
  84. BASICA COLOR in a batch file called C.BAT.  Then, just executing C
  85. will set your colors.
  86.      The ANSI and PROMPT method is a little more complex at first, but
  87. once done you don't have to fuss with it.  Many applications programs
  88. reset the video mode and clear the screen when they start up.  So,
  89. after you get out of these programs, you'd have to execute the COLOR
  90. program again.  With the ANSI and PROMPT method, you don't have to do
  91. anything.
  92.      If you use the BASIC program rather than the PROMPT command for
  93. setting your colors, do not load ANSI.SYS.  ANSI.SYS will use its
  94. default color values (gray on black) instead of those that BASIC sets.
  95.  
  96. -----------------------------------------------------------------
  97.                        Fast Screen Colors
  98.              (PC World February 1987 Star-Dot-Star)
  99.  
  100.      SCREEN.BAT uses 16 IFs (and no GOTOs) to set screen colors at the
  101. DOS level.  GOTO statements slow batch file execution because the
  102. command processor always starts at the beginning of the batch file
  103. when searching for a label.
  104.  
  105. echo off
  106. cls
  107. set temp=%prompt%
  108. echo Changing colors ....
  109. set fgc=7
  110. if %1!==black!    set fgc=0
  111. if %1!==red!      set fgc=1
  112. if %1!==green!    set fgc=2
  113. if %1!==yellow!   set fgc=3
  114. if %1!==blue!     set fgc=4
  115. if %1!==magenta!  set fgc=5
  116. if %1!==cyan!     set fgc=6
  117. if %1!==white!    set fgc=7
  118. set bgc=0
  119. if %2!==black!    set bgc=0
  120. if %2!==red!      set bgc=1
  121. if %2!==green!    set bgc=2
  122. if %2!==yellow!   set bgc=3
  123. if %2!==blue!     set bgc=4
  124. if %2!==magenta!  set bgc=5
  125. if %2!==cyan!     set bgc=6
  126. if %2!==white!    set bgc=7
  127. prompt $e[3%fgc%;4%bgc%m
  128. echo on
  129. echo off
  130. cls
  131. prompt %temp%
  132. echo New colors now in effect
  133. set fgc=
  134. set bgc=
  135. set temp=
  136.  
  137.